package com.weakteam.mobile.minimum.common.util;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;

import java.util.HashMap;

/**
 * Created by Nail Sharipov (nailxsharipov@gmail.com) on 10.11.2014.
 */
public class FontManager {

    private static final HashMap<String, Typeface> fontsCache = new HashMap<String, Typeface>();

    public static Typeface loadFont(String fontName, Context context) {
        Typeface font = fontsCache.get(fontName);

        if (font == null) {
            //font = Typeface.createFromAsset(context.getAssets(), "assets/fonts/" + fontName);
            final AssetManager assetManager = context.getAssets();
            font = Typeface.createFromAsset(assetManager, fontName);
            fontsCache.put(fontName, font);
        }

        return font;
    }
}
